package com.jms.fu.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.jms.fu.exception.DAOException;
import com.jms.fu.model.bean.User;
import com.jms.fu.model.bo.UserBO;

public class GetBalanceAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){
		
		HttpSession session = request.getSession();
		String username = (String)session.getAttribute("username");
		UserBO userbo = new UserBO();
		try {
			PrintWriter out = response.getWriter();
			User user = userbo.getUserInfoByUsername(username);
			out.print(user.getBalance());
		} catch (DAOException | IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	
}
